package com.neusoft.controller;

import com.neusoft.domain.Employee;
import com.neusoft.domain.Food;
import com.neusoft.domain.PageResult;
import com.neusoft.domain.Result;
import com.neusoft.domain.Vo.FoodVo;
import com.neusoft.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/foods")
public class FoodController {
    @Autowired
    private FoodService foodService;
    @GetMapping("/findFoodByPageAndShopId")
    public Result findFoodByPageAndShopId(@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize") Integer pageSize,@RequestParam("foodName") String foodName,@RequestParam("shopId") Integer shopId){
        PageResult<FoodVo> pageResult = foodService.findFoodByPageAndShopId(pageNum, pageSize, foodName, shopId);
        return Result.success(pageResult);
    }
    @PutMapping("/updateFood")
    public Result updateFood(@RequestBody Food food){
        foodService.updateFood(food);
        return Result.success();
    }
    @PostMapping("addFood")
    public Result addFood(@RequestBody Food food){
        foodService.addFood(food);
        return Result.success();
    }


    @PutMapping("/changeFoodStatus")
    public Result changeFoodStatus(@RequestBody Food food){
        Integer foodId = food.getFoodId();
        Integer status = Integer.valueOf(food.getStatus());
        foodService.changeFoodStatus(foodId, status);
        return Result.success();
    }
    @PutMapping("/recommendFood")
    public Result recommendFood(@RequestBody Food food){
        Integer foodId = food.getFoodId();
        Integer recommend = Integer.valueOf(food.getRecommend());
        foodService.recommendFood(foodId, recommend);
        return Result.success();
    }
    @PutMapping("/hotFood")
    public Result hotFood(@RequestBody Food food){
        Integer foodId = food.getFoodId();
        Integer hot = Integer.valueOf(food.getHot());
        foodService.hotFood(foodId, hot);
        return Result.success();
    }
}
